import pandas as pd
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn import model_selection

def data_process():
    data_attack = pd.read_csv('attack.csv')
    data_resource = pd.read_csv('resource.csv')
    x =np.array( data_attack['名次']).reshape(-1,1)
    y = np.array(data_attack['KDA']).reshape(-1,1)
    predictors = ['KDA', '场均击杀', '场均死亡', '每分钟伤害', '一血率',
                  '场均时长', '场均经济', '每分钟经济', '每分钟补刀']
    return data_attack,predictors

def logic(data_train,predicators):
    LogRegAlg =  LogisticRegression(random_state=1)
    LogRegAlg.fit(data_train[predicators],data_train['名次'])
    # 使用sklearn库里面的交叉验证函数获取预测准确率分数
    scores = model_selection.cross_val_score(LogRegAlg,data_train[predicators],data_train['名次'],cv=2)
    # 使用交叉验证分数的平均值作为最终的准确率
    print("逻辑回归准确率为: ", scores.mean())

if __name__ == '__main__':
    x , y  = data_process()
    logic(x,y)


